<?php
class Order_IndexMain
{
	public function index($orderManager)
	{
		$dtMainIndex = new DataTable(constant('DB_TABLE_ORDER_INDEX_MAIN'));
		$orderInfo = $orderManager->getInfo();
		//remove index if exist
		$dtMainIndex->remove($orderManager->getId());
		$gift_list = '';
		foreach($orderInfo['zoom_list'] as $tmpData)
		{
			$gift_list .= $tmpData['size_name'].',';
		}
		foreach($orderInfo['zoom_frame_list'] as $tmpData)
		{
			$gift_list .= $tmpData['frame_name'].',';
		}
		foreach($orderInfo['gift_list'] as $tmpData)
		{
			$gift_list .= $tmpData['gift_name'].',';
		}
		$indexData = array(
			'manager_id'=>$orderManager->getId(),
			'order_number'=>$orderInfo['number'],
			'status'=>$orderInfo['status'],
			'c_name'=>$orderInfo['customerinfo']['name'],
			'c_birthday_year'=>$orderInfo['customerinfo']['birthday']['year'],
			'c_birthday_month'=>$orderInfo['customerinfo']['birthday']['month'],
			'c_birthday_date'=>$orderInfo['customerinfo']['birthday']['date'],
			'c_mobile'=>$orderInfo['customerinfo']['mobile'],
			'c_email'=>$orderInfo['customerinfo']['email'],
			'c_email2'=>$orderInfo['customerinfo']['email2'],
			
			'c_tel' => $orderInfo['customerinfo']['tel']['part_one'].$orderInfo['customerinfo']['tel']['part_two'],
			'c_tel_part_one'=>$orderInfo['customerinfo']['tel']['part_one'],
			'c_tel_part_two'=>$orderInfo['customerinfo']['tel']['part_two'],
			
			'c_address_one'=>$orderInfo['customerinfo']['address']['part_one'],
			'c_address_two'=>$orderInfo['customerinfo']['address']['part_two'],
			'c_address_three'=>$orderInfo['customerinfo']['address']['part_three'],
			
			'photo_time'=>$orderInfo['workflow']['photo_time'],
			'proof_time'=>$orderInfo['workflow']['proof_time'],
			'pickup_time'=>$orderInfo['workflow']['pickup_time'],
			'created'=>$orderInfo['created'],
			'created_by_user'=>$orderInfo['created_by_user'],
			'already_photo'=>$orderInfo['already_photo'],
			'already_proof'=>$orderInfo['already_proof'],
			'already_pickup'=>$orderInfo['already_pickup'],
			'gift_list'=>$gift_list,
			'total_price'=>$orderInfo['price']['total']
		);
		$dtMainIndex->insert($indexData);
	}
}
?>